home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 12.4 KB | 282 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWEventH.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWEVENTH_H
- #define FWEVENTH_H
-
- #ifndef FWSTDDEF_H
- #include "FWStdDef.h"
- #endif
-
- #ifndef FWRUNTYP_H
- #include "FWRunTyp.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _ODTYPES_
- #include <ODTypes.h>
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CPoint;
- class FW_CLASS_ATTR FW_CNullEvent;
- class FW_CLASS_ATTR FW_CMouseEvent;
- class FW_CLASS_ATTR FW_CEmbeddedMouseEvent;
- class FW_CLASS_ATTR FW_CBorderMouseEvent;
- class FW_CLASS_ATTR FW_CVirtualKeyEvent;
- class FW_CLASS_ATTR FW_CCharKeyEvent;
- class FW_CLASS_ATTR FW_CActivateEvent;
- class FW_CLASS_ATTR FW_CSuspendResumeEvent;
- class FW_CLASS_ATTR FW_CMenuEvent;
- class FW_CLASS_ATTR FW_CMacWindowEvent;
- class FW_CLASS_ATTR FW_CMenuBar;
- class FW_CLASS_ATTR ODFrame;
- class FW_CLASS_ATTR ODFacet;
- class FW_CLASS_ATTR FW_CPrivOrderedCollection;
- class FW_CLASS_ATTR FW_MEventHandler;
-
- //========================================================================================
- // typedef
- //========================================================================================
-
- typedef unsigned long FW_Priority;
-
- //========================================================================================
- // Constants
- //========================================================================================
-
- const ODID kNoIdentifier = 0xFFFFFFFFL;
- const FW_Priority kNoPriority = 1000; // Pick some large number here?
-
- //========================================================================================
- // struct FW_SEventHandlerPartInfo
- //========================================================================================
- // We put a pointer of this structure into the partInfo of a frame. FW_SEventHandlerPartInfo
- // is subclassed in the framework layer.
-
- struct FW_SEventHandlerPartInfo
- {
- FW_MEventHandler* fEventHandler;
- };
-
- //========================================================================================
- // class FW_MEventHandler
- //========================================================================================
-
- class FW_CLASS_ATTR FW_MEventHandler
- {
- public:
- FW_DECLARE_CLASS
-
- typedef FW_MEventHandler* FW_MEventHandlerPtr;
- typedef ODID EventHandlerId;
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructor
- //
- protected:
- FW_MEventHandler();
- FW_MEventHandler(Environment* ev, ODID theID, FW_MEventHandler* nextEventHandler, FW_Boolean enabled, FW_Priority thePriority);
-
- public:
- virtual ~ FW_MEventHandler();
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- ODID GetIdentifier(Environment* ev) const;
- virtual void SetIdentifier(Environment* ev, ODID identifier);
-
- FW_MEventHandler* GetNextEventHandler(Environment* ev) const;
- void SetNextEventHandler(Environment* ev, FW_MEventHandler* nextEventHandler);
-
- virtual FW_Boolean IsActive(Environment* ev) const;
- virtual FW_Boolean Activate(Environment* ev);
- virtual void Deactivate(Environment* ev);
-
- virtual FW_Boolean IsEnabled(Environment* ev) const;
- virtual FW_Boolean Enable(Environment* ev);
- virtual void Disable(Environment* ev);
-
- virtual FW_Priority GetPriority(Environment* ev) const;
- virtual void SetPriority(Environment* ev, FW_Priority thePriority);
-
- // ----- Event handler management -----
-
- virtual void AdoptEventHandler(Environment* ev, FW_MEventHandler* eventHandler);
- virtual FW_MEventHandler* RemoveEventHandler(Environment* ev, ODID theID);
- virtual FW_MEventHandler* RemoveEventHandler(Environment* ev, FW_MEventHandler* eventHandler);
-
- // ----- Event Handling Protocal -----
-
- virtual FW_Boolean HandleIdle(Environment* ev, const FW_CNullEvent& theNullEvent);
- virtual FW_Boolean DoIdle(Environment* ev, const FW_CNullEvent& theNullEvent);
-
- virtual FW_Boolean HandleMouseEnter(Environment* ev, ODFacet* odFacet, const FW_CPoint& theMousePoint);
- virtual FW_Boolean DoMouseEnter(Environment* ev, ODFacet* odFacet, const FW_CPoint& theMousePoint);
-
- virtual FW_Boolean HandleMouseWithin(Environment* ev, ODFacet* odFacet, const FW_CPoint& theMousePoint);
- virtual FW_Boolean DoMouseWithin(Environment* ev, ODFacet* odFacet, const FW_CPoint& theMousePoint);
-
- virtual FW_Boolean HandleMouseLeave(Environment* ev, ODFacet* odFacet);
- virtual FW_Boolean DoMouseLeave(Environment* ev, ODFacet* odFacet);
-
- virtual FW_Boolean HandleMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent);
- virtual FW_Boolean DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent);
-
- virtual FW_Boolean HandleBGMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent);
- virtual FW_Boolean DoBGMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent);
-
- virtual FW_Boolean HandleMouseUp(Environment* ev, const FW_CMouseEvent& theMouseEvent);
- virtual FW_Boolean DoMouseUp(Environment* ev, const FW_CMouseEvent& theMouseEvent);
-
- virtual FW_Boolean HandleMouseDownInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
- virtual FW_Boolean DoMouseDownInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
-
- virtual FW_Boolean HandleBGMouseDownInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
- virtual FW_Boolean DoBGMouseDownInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
-
- virtual FW_Boolean HandleMouseUpInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
- virtual FW_Boolean DoMouseUpInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
-
- virtual FW_Boolean HandleMouseDownInEmbeddedFrameBorder(Environment* ev, const FW_CBorderMouseEvent& theBorderMouseEvent);
- virtual FW_Boolean DoMouseDownInEmbeddedFrameBorder(Environment* ev, const FW_CBorderMouseEvent& theBorderMouseEvent);
-
- virtual FW_Boolean HandleVirtualKey(Environment* ev, const FW_CVirtualKeyEvent& theVirtualKeyEvent);
- virtual FW_Boolean DoVirtualKey(Environment* ev, const FW_CVirtualKeyEvent& theVirtualKeyEvent);
-
- virtual FW_Boolean HandleCharKey(Environment* ev, const FW_CCharKeyEvent& theCharKeyEvent);
- virtual FW_Boolean DoCharKey(Environment* ev, const FW_CCharKeyEvent& theCharKeyEvent);
-
- virtual FW_Boolean HandleActivateEvent(Environment* ev, const FW_CActivateEvent& theActivateEvent);
- virtual FW_Boolean DoActivateEvent(Environment* ev, const FW_CActivateEvent& theActivateEvent);
-
- virtual FW_Boolean HandleSuspendResumeEvent(Environment* ev, const FW_CSuspendResumeEvent& theSuspendResumeEvent);
- virtual FW_Boolean DoSuspendResumeEvent(Environment* ev, const FW_CSuspendResumeEvent& theSuspendResumeEvent);
-
- virtual FW_Boolean HandleMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent);
- virtual FW_Boolean DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent);
-
- virtual FW_Boolean HandleAdjustMenus(Environment *ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot);
- virtual FW_Boolean DoAdjustMenus(Environment *ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot);
-
- #ifdef FW_BUILD_MAC
- virtual FW_Boolean HandleWindowEvent(Environment* ev, const FW_CMacWindowEvent& windowEvent);
- virtual FW_Boolean DoWindowEvent(Environment* ev, const FW_CMacWindowEvent& windowEvent);
- #endif
-
- // ----- Target management -----
-
- virtual FW_MEventHandler* GetTarget(Environment* ev) const;
- virtual void SetTarget(Environment* ev, FW_MEventHandler* theTarget);
- virtual FW_Boolean IsTarget(Environment* ev);
- virtual FW_Boolean BecomeTarget(Environment* ev);
- virtual FW_Boolean ResignTarget(Environment* ev);
- virtual FW_Boolean WantsToBeTarget(Environment* ev);
- virtual long WillingToResignTarget(Environment* ev);
- virtual void TargetValidationSucceeded(Environment* ev);
- virtual void TargetValidationFailed(Environment* ev, long reason);
-
- // ----- Private Method -----
- virtual FW_MEventHandler* PrivGetEventHandlerContaining(Environment* ev, ODFacet* facet, const FW_CPoint& whereInFrame);
-
- //------------------------------------------------------------------------------------
- // Conversion utilities
- //------------------------------------------------------------------------------------
-
- static FW_MEventHandler* ODFrameToEventHandler(Environment* ev, ODFrame* theFrame);
-
- //------------------------------------------------------------------------------------
- // Internal use Only
- //
- public:
- // ----- Dispatching -----
- FW_Boolean DispatchMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent);
- FW_Boolean DispatchBGMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent);
- FW_Boolean DispatchMouseUp(Environment* ev, const FW_CMouseEvent& theMouseEvent);
- FW_Boolean DispatchIdle(Environment* ev, const FW_CNullEvent& theNullEvent);
- FW_Boolean DispatchMouseEnter(Environment* ev, ODFacet* odFacet, const FW_CPoint& theMousePoint);
- FW_Boolean DispatchMouseWithin(Environment* ev, ODFacet* odFacet, const FW_CPoint& theMousePoint);
- FW_Boolean DispatchMouseLeave(Environment* ev, ODFacet* odFacet);
- FW_Boolean DispatchMouseDownInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
- FW_Boolean DispatchBGMouseDownInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
- FW_Boolean DispatchMouseUpInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
- FW_Boolean DispatchMouseDownInEmbeddedFrameBorder(Environment* ev, const FW_CBorderMouseEvent& theBorderMouseEvent);
- FW_Boolean DispatchVirtualKey(Environment* ev, const FW_CVirtualKeyEvent& theVirtualKeyEvent);
- FW_Boolean DispatchCharKey(Environment* ev, const FW_CCharKeyEvent& theCharKeyEvent);
- FW_Boolean DispatchActivateEvent(Environment* ev, const FW_CActivateEvent& theActivateEvent);
- FW_Boolean DispatchSuspendResumeEvent(Environment* ev, const FW_CSuspendResumeEvent& theSuspendResumeEvent);
- FW_Boolean DispatchMenuEvent(Environment* ev, const FW_CMenuEvent& theMenuEvent);
- FW_Boolean DispatchAdjustMenus(Environment *ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot);
-
- #ifdef FW_BUILD_MAC
- FW_Boolean DispatchWindowEvent(Environment* ev, const FW_CMacWindowEvent& windowEvent);
- #endif
-
- protected:
- virtual void CreateEventHandlers(Environment* ev);
-
- private:
- void PrivInsert(Environment* ev, FW_MEventHandler* eventHandler);
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- ODID fIdentifier;
- FW_MEventHandler *fNextEventHandler;
- FW_Boolean fActive;
- FW_Boolean fEnabled;
- FW_Priority fPriority;
- FW_CPrivOrderedCollection* fEventHandlers;
- };
-
- //========================================================================================
- // Inlines
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_MEventHandler::GetIdentifier()
- //----------------------------------------------------------------------------------------
- inline ODID FW_MEventHandler::GetIdentifier(Environment* ev) const
- {
- return fIdentifier;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_MEventHandler::GetNextEventHandler()
- //----------------------------------------------------------------------------------------
- inline FW_MEventHandler* FW_MEventHandler::GetNextEventHandler(Environment* ev) const
- {
- return fNextEventHandler;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_MEventHandler::SetNextEventHandler()
- //----------------------------------------------------------------------------------------
- inline void FW_MEventHandler::SetNextEventHandler(Environment* ev, FW_MEventHandler* nextEventHandler)
- {
- fNextEventHandler = nextEventHandler;
- }
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-